#ifndef ADPCM_SOURCE_FILTER_H
#define ADPCM_SOURCE_FILTER_H

#include <deque>
#include "SimpleMemPool.h"

using namespace std;

class CPushPinAdpcmAudio;
typedef pool_ptr<char> DataBuffer;
typedef deque< pair<DataBuffer, int> > DATASTORAGE;

class CPushSourceAdpcmAudio : public CSource
{
public:
	CPushSourceAdpcmAudio(IUnknown *pUnk, HRESULT *phr, int channels, int sampleRate, int bitsPerSample, AudioCodecId codecId);
	~CPushSourceAdpcmAudio();

	IPin *GetOutputPin();
	int GetAdpcmData(DataBuffer& dataBuffer);

	int PlayAdpcmData(char *data, int len);

	STDMETHODIMP Stop();
	STDMETHODIMP Pause();
	void ClearBuffer();

private:
	CPushPinAdpcmAudio *m_pPin;

	CCritSec m_bufferLock;
	DATASTORAGE m_dataBuffers;
	bool m_isShutdowning;
	AudioCodecId m_codecId;
	DWORD m_dwDelay;
	DWORD m_dwStartTimeTick;
	CSimpleMemPool<char> m_dataBufferPool;
};

#endif

